var timerInterval;      //调度器对象
var runNum = 0;
function moveBanner() {
    let ul = document.getElementById('banner_ul');
    let len = ul.children.length;
    let width = ul.children[0].offsetWidth;
    //获取转折点
    let resetLeft = -(len - 1) * width;
    //计算步长
    let step = width / 400;
    let time = 10;
    move(ul, step, time, resetLeft);

    let divBox = document.getElementById('banner');
    divBox.onmouseover = () => {
        clearMoveInterval(timerInterval);
    }
    divBox.onmouseout = () => {
        move(ul, step, time, resetLeft);
    }
}

function clearMoveInterval(timer) {
    if (timer) {
        clearInterval(timer);
        timer = null;
    }
}

function move(target, step, time, stop) {
    clearMoveInterval(timerInterval);
    timerInterval = setInterval(() => {
        runNum -= step;
        if (runNum <= stop) {
            runNum = 0;
        }
        target.style.left = runNum + 'px';
    }, time);
}

moveBanner();